<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <link rel="stylesheet" href="css/layer.css" />
    <link rel="stylesheet" href="css/style.css" />
	<link rel="icon" href="images/favicon.png">
</head>
<body>
	<header class="mui-bar mui-bar-nav" id="head">
		<a class="back_a">
			<img src="images/back.png"/>
		</a>
		<span class="mui-title">审核升级</sapn>
		<a onclick="history()" class="back_sj">历史订单</a>
	</header>

</body>
<script type="text/javascript" src="js/jquery.js" ></script>
<script type="text/javascript" src="js/layer.js" ></script>
<script type="text/javascript">
    //返回上一级
    $(".back_a").click(function(){
        window.location.href ="/index";
    })
    //审核升级
    function history(){
        window.location.href ="/history";
    }
	//获取正在申请的信息
	var storage=window.localStorage;
	var token=storage.token;
	if(token==undefined){
		window.location.href = "/"
	}
	$.ajax({
		type: "GET",
		url: "/users/verify/verifyVipList?token="+token,
		contentType: "application/json;charset=UTF-8",
		data:"",
		dataType: "json",
		success: function (data) {
			if (data.code && data.code==='success') {
				var html = '';
				for (var i = 0; i < data.data.length;i++){
					html += '<div class="install_bg">'+
							'<p class="apply_op">姓名：<span class="apply_vip">'+data.data[i].userName+'</span></p>'+
							'<p class="apply_op">申请等级：<span class="apply_two">'+data.data[i].nextIdentityName+'</span></p>'+
							'<p class="apply_op">手机号码：<span class="apply_phone">'+data.data[i].mobileNumber+'</span></p>'+
							'<p class="apply_op">微信号：<span class="apply_wx">'+data.data[i].weChat+'</span></p>'+
							'</div>'+
							'<div class="install_btn tj" onclick="pass(\''+data.data[i].id+'\')">同意</div>';
				}
				$("#head").append(html);
			} else {
				layer.msg(data.message,{icon:2,time:1000});
			}
		},
		error: function (data) {
            if(data.code==undefined){
                layer.msg("登录失效",{icon:2,time:1000});
                setTimeout(function() { window.location.href = "/"; }, 2000 );
            }
			layer.msg(data.message,{icon:2,time:1000});
		}
	});

	//审核通过
	function pass(id) {
		$.ajax({
			type: "POST",
			url: "/users/verify/verifyVip?token="+token,
			contentType: "application/json;charset=UTF-8",
			data:JSON.stringify({"apply_id":id}),
			dataType: "json",
			success: function (data) {
				if (data.code && data.code==='success') {
					layer.msg(data.message,{icon:2,time:1000});
					window.location.reload();
				} else {
					layer.msg(data.message,{icon:2,time:1000});
				}
			},
			error: function (data) {
                if(data.code==undefined){
                    layer.msg("登录失效",{icon:2,time:1000});
                    window.location.href ="/";
                }
				layer.msg(data.message,{icon:2,time:1000});
			}
		});
	}
</script>
</html>